<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <title>出库单</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link href="/dist/plugins/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/dist/plugins/webuploader-0.1.5/webuploader.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=f5a12a1d">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style>
        select {
            background: transparent;
            border: none;
            outline: none;
        }

        .model-picker-input {
            opacity: 0 !important;
            top: -9999px;
            left: -9999px;
            position: absolute;
        }

        .model-picker-span {
            position: relative;
            display: block;
            outline: 0;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            border-bottom: 1px solid #ccc;
            background-color: #fff;
            color: #ccc;
            cursor: pointer;
        }

        .model-picker-span > .placeholder {
            color: #aaa;
        }

        .model-picker-span > .arrow {
            position: absolute;
            top: 50%;
            right: 8px;
            width: 10px;
            margin-top: -3px;
            height: 5px;
            background: url(../images/drop-arrow.png) -10px -25px no-repeat;
        }

        .model-picker-span.focus,
        .model-picker-span.open {
            border-bottom-color: #46A4FF;
        }

        .model-picker-span.open > .arrow {
            background-position: -10px -10px;
        }

        .model-picker-span > .title > span {
            color: #333;
            padding: 5px;
            border-radius: 3px;
        }

        .model-picker-span > .title > span:hover {
            background-color: #f1f8ff;
        }

        .model-picker-dropdown {
            position: absolute;
            width: 315px;
            left: -9999px;
            top: -9999px;
            outline: 0;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            z-index: 999999;
            display: none;
            min-width: 200px;
            margin-bottom: 20px;
            margin-top: 5px;
        }

        .model-select-wrap {
            box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
        }

        .model-select-tab {
            border-bottom: 1px solid #ccc;
            background: #f5f5f5;
            /*font-size: 13px;*/
        }

        .model-select-tab > a {
            display: inline-block;
            padding: 4px 20px;
            border-left: 1px solid #ccc;
            border-bottom: 1px solid transparent;
            color: #4D4D4D;
            text-align: center;
            outline: 0;
            text-decoration: none;
            cursor: pointer;
            /*font-size: 14px;*/
            margin-bottom: -1px;
        }

        .model-select-tab > a.active {
            background: #fff;
            border-bottom: 1px solid #fff;
            color: #46A4FF;
        }

        .model-select-tab > a:first-child {
            border-left: none;
        }

        .model-select-tab > a:last-child.active {
            border-right: 1px solid #ccc;
        }

        .model-select-content {
            width: 100%;
            min-height: 50px;
            background-color: #fff;
            padding: 5px 5px;
        }

        .model-select dl {
            line-height: 2;
            clear: both;
            padding: 3px 0;
            margin: 0;
            max-height: 200px;
            overflow-y: scroll;
        }

        .model-select dt {
            position: absolute;
            width: 2.5em;
            font-weight: 500;
            text-align: right;
            line-height: 2;
        }

        .model-select dd {
            margin-left: 0;
            line-height: 2;
        }

        .model-select.province dd {
            margin-left: 3em;
        }

        .model-select a {
            display: inline-block;
            padding: 0 10px;
            outline: 0;
            text-decoration: none;
            white-space: nowrap;
            margin-right: 2px;
            color: #333;
            cursor: pointer;
        }

        .model-select a:hover,
        .model-select a:focus {
            background-color: #f1f8ff;
            border-radius: 2px;
            color: #46A4FF;
        }

        .model-select a.active {
            background-color: #46A4FF;
            color: #fff;
            border-radius: 2px;
        }

        .table-detail input[type=text] {
            padding-left: 0;

        }

        td {
            color: #2a8cec;
        }

        td.td-title, td select, td .filename, td.td-module {
            color: #333;
        }

        select {
            color: rgb(42, 140, 236) !important;
            background: #fff;
        }

        .table-detail td {
            /*font-size: 16px;*/
            line-height: 35px;
            height: 35px;
            border-right: 1px solid #cbcbcb;
            border-bottom: 1px solid #cbcbcb;
        }

        .table-detail td.td-title {
            line-height: 1.5;
            background: #F5F5F5;
        }

        .table-detail td.td-row3 {
            height: 70px;
            line-height: 20px;
            max-height: 70px;
            overflow: hidden;
            position: relative;
        }

        .yuying {
            position: absolute;
            right: 10px;
            bottom: 10px;
            width: 20px;
            height: 20px;
            background: url("/dist/img/yuyin.png");
            background-size: cover;
            cursor: pointer;
        }

        input {
            text-align: left !important;
        }

        .table-detail td.td-value {
            text-align: left !important;
            padding-left: 4px !important;
            /*font-size: 16px !important;*/
        }

        .btn-group-xs > .btn, .btn-xs {
            padding: 1px 5px;
            /*font-size: 16px;*/
            line-height: 1.5;
            border-radius: 3px;
        }

        .table-detail textarea {
            height: 60px;
            width: 100%;
            border: none;
            outline: none;
            -webkit-appearance: none;
            resize: none;
            line-height: 20px;
            padding-top: 2px !important;
            padding-left: 6px;
        }

        .td-row3 span {
            max-height: 60px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
            text-align: left;

        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .td-module td {
            color: black;
            font-weight: bold;
            background: yellow;
        }

        .table-detail {
            border-left: 1px solid #cbcbcb;
            border-top: 1px solid #cbcbcb;
        }

        .table-detail .td-module {
            background-color: yellow;
        }

        span.lineOne {
            line-height: 20px;
            height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
        }

        .table-detail td.td-value2 {
            padding: 1px !important;
            text-align: left !important;
        }

        .td-value2 input {
            box-shadow: inset 1px 1px 4px #333;
            height: 100% !important;
            padding-left: 4px !important;
        }

        .span-a-btn {
            position: absolute;
            right: 10px;
        }

        .table-detail td.td-value {
            text-align: left !important;
            padding-left: 4px !important;
            /*font-size: 16px !important;*/
        }

        .jiaobiao3 {
            position: relative;
        }

        .jiaobiao3 i {
            display: block;
            width: 10px;
            height: 10px;
            background: url("/dist/img/newLog3.png");
            position: absolute;
            top: 0px;
            right: 0px;
        }

        .moreListData {
            position: absolute;
            top: 30px;
            z-index: 111;
            display: none;
        }

        .moreListData .item {
            width: 100%;
            height: 30px;
            line-height: 30px;
        }

        .moreListData .item span {
            margin-right: 5px;
        }

        .ui_main {
            vertical-align: top;
        }

        .table-detail input[type=text], .table-detail input[type=number], .table-detail input[type=tel], .table-detail select {
            margin-left: 0px;
            margin-right: 0px;
        }

        .user {
            height: 30px;
            line-height: 30px;
            max-height: 30px;
            float: left;
            text-align: left;
            min-width: 32px;
            padding-left: 1px;
            overflow: hidden;
            cursor: pointer;
        }

        .user:hover {
            background-color: #cfd4d1;
        }

        .userbox .select.user {
            color: #fff;
            background-color: #045B9E;
        }

        .span-btn {
            position: absolute;
            left: 10px;
            margin-top: 4px;
            cursor: pointer;
        }

        .auditorName {
            text-align: center !important;
        }


        .progressobj {
            height: 20px;
        }

        .progressobj .delfile {
            float: left;
            margin-left: 10px;
        }

        .select {
            color: #fff;
            background-color: #045B9E;
        }

        td .sp-value {
            display: inline-block;
            padding-left: 6px;
            word-wrap: break-word;
        }

        td {
            color: #2a8cec;
        }

        td.td-title, td select, td .filename, td.td-module {
            color: black;
            font-weight: normal !important;
        }

        .table-detail-payee:nth-child(even) td.td-title {
            background-color: white;
        }

        .printDiv {
            display: none;
        }

        .webuploader-pick {
            background: url(/dist/img/fjT1.png) no-repeat 5px center;
            display: block;
            padding: 0 4px;
            height: 22px;
            line-height: 22px;
            padding-left: 15px;
            margin: 0 auto;
            width: 70px;
            margin-top: 6px;
            border-radius: 4px;
        }

        .webuploader-pick-hover {
            color: #fff !important;
            background: url(/dist/img/fjT2.png) no-repeat 5px center;
            background-color: #0F6099;

        }


    </style>
</head>
<body>
<iframe id="ifAttach" style="display:none"></iframe>
<div class="layout" style="left:0px;top:0px;right:0px;bottom:0px;" id="app">
    <!--<h4 class="text-center">行政物品申请</h4>-->
    <div class="center" style="padding-left:8px;padding-right:8px;">
        <table class="table-detail">
            <tr class="td-module">
                <td colspan="4">出库单</td>
            </tr>
            <tr>
                <td class="td-title" style="width: 25%;">出库日期</td>
                <td class="td-tanZongStyle" style="width: 25%;">
                    {{repo.main.date}}
                </td>
                <td class="td-title" style="width: 25%;">出库人</td>
                <td class="td-tanZongStyle" style="width: 25%;">
                    {{repo.main.outUserName}}
                </td>
            </tr>
            <template v-if="pageType=='edit'">
                <tr>
                    <td class="td-title" style="width: 25%;">物品名称</td>
                    <td class="td-tanZongStyle" style="width: 25%;" colspan="3">
                        {{inventoryGoods.main.goodsName}}
                    </td>
                    <!--<td class="td-title" style="width: 25%;">库存数量</td>
                    <td class="td-tanZongStyle" style="width: 25%;">
                        {{inventoryGoods.main.count}}
                    </td>-->
                </tr>
            </template>
            <template v-else>
                <tr>
                    <td class="td-title" style="width: 25%;">物品名称</td>
                    <td class="td-tanZongStyle" style="width: 25%;">
                        {{repo.main.goodsName}}
                    </td>
                    <td class="td-title" style="width: 25%;">出库数量</td>
                    <td class="td-tanZongStyle" style="width: 25%;">
                        <input type="text" v-if="pageType=='edit'" v-model="repo.main.count" class="validators"
                               placeholder="请输入"/>
                        <span v-else style="padding-left: 4px;">{{repo.main.count}}</span>
                    </td>
                    <!--<td class="td-title" style="width: 25%;">库存数量</td>
                    <td class="td-tanZongStyle" style="width: 25%;">
                        {{repo.main.goodsCount}}
                    </td>-->
                </tr>
            </template>
                <!--<tr>
                    <td class="td-title" style="width: 25%;">出库数量</td>
                    <td class="td-tanZongStyle" style="width: 25%;">
                        <input type="text" v-if="pageType=='edit'" v-model="repo.main.count" class="validators"
                               placeholder="请输入"/>
                        <span v-else style="padding-left: 4px;">{{repo.main.count}}</span>
                    </td>
                    <td class="td-title" style="width: 25%;">领用人</td>
                    <td class="td-tanZongStyle" style="width: 25%;">
                        <input type="text" v-if="pageType=='edit'" v-model="repo.main.receiveUserName" class="validators"
                               placeholder="请输入"/>
                        <span v-else style="padding-left: 4px;">{{repo.main.receiveUserName}}</span>
                    </td>
                </tr>-->
            <!--<tr>
                <td class="td-title" style="width: 25%;">领用时间</td>
                &lt;!&ndash;<td class="td-tanZongStyle" style="width: 25%;">
                    <input type="text" v-if="pageType=='edit'" v-model="repo.main.name" class="validators"
                           placeholder="请输入"/>
                    <span v-else style="padding-left: 4px;">{{repo.main.name}}</span>&ndash;&gt;
                <td class="td-tanZongStyle" style="width: 25%;">
                    <input type="text" v-model="repo.main.receiveDate" v-if="pageType=='edit'"
                           @focus="showDatePicker($event)" placeholder="请选择时间"/>
                    <span v-else style="padding-left: 4px;">{{repo.main.receiveDate}}</span>
                </td>
                </td>
            </tr>-->
            <tr>
                <td class="td-title" style="width: 25%;">出库用途</td>
                <td class="td-tanZongStyle" style="width: 25%;" colspan="3">
                    <input type="text" v-if="pageType=='edit'" v-model="repo.main.remark" class="validators"
                           placeholder="请输入"/>
                    <span v-else style="padding-left: 4px;">{{repo.main.remark}}</span>
                </td>
            </tr>
            <tr>
                <td class="td-title">领用凭证</td>
                <td :colspan="pageType=='edit'?2:3">
                    <div id="divUploadedFiles">
                        <div v-for="(attach,i) in repo.attaches" class="fj-tanzhongStyle ">
                            <b :class="fjStyle(attach.name)"></b>
                            <div class="name" v-if="attach.name" :title="attach.name"
                                 v-on:click="download(attach.url,attach.name)">
                                {{attach.name}}
                            </div>
                            <div class="down">
                                <a href="javascript:void(0)" class="nui-txt-link"
                                   v-on:click="download(attach.url,attach.name)">
                                    下载
                                </a>
                            </div>
                            <div class="del" v-if="pageType=='edit'">
                                <a href="javascript:void(0)" class="nui-txt-link" v-on:click="deleteFile(i)">
                                    删除
                                </a>
                            </div>
                        </div>
                    </div>
                </td>
                <td v-if="pageType=='edit'">
                    <div id="divUpload" class="rightBorder fj fujian Hfj">
                        上传图片
                    </div>
                </td>
            </tr>
        </table>
        <!--审批进度-->
        <table class="table-detail no-print" style="border-top-width:0px;">
            <tr>
                <td class=" td-module" colspan="5" style="background: yellow;">审批进度</td>
            </tr>
            <tr>
                <td class="td-title" style="width:16%;">审核顺序</td>
                <td class="td-title" style="width:17%;">审核人员</td>
                <td class="td-title" style="width:16%;">审核状态</td>
                <td class="td-title" style="width:17%;">审核时间</td>
                <td class="td-title">审核意见</td>
            </tr>
            <tr v-for="(item,i) in repo.auditors">
                <td>
                    <span v-if="pageType=='edit'" class="span-btn">
                        <span style="font-size:20px;"
                              @click="addItem('auditors','Audit')"> + </span>
                        <span style="font-size:20px;"
                              @click="delItem('auditors',i,'审核人')"> - </span>
                    </span>
                    <span>第{{i+1}}审核人</span>
                </td>
                <td>
                    <input v-if="pageType=='edit'" class="auditorName" type="text"
                           :value="item.auditorName" :idx="i"/>
                    <span v-else>{{item.auditorName}}</span>
                </td>
                <td>
                    <span v-if="item.auditFlag==0" style="color:red;">{{convertAuditFlagToName(item.auditFlag)}}</span>
                    <span v-else>{{convertAuditFlagToName(item.auditFlag)}}</span>
                </td>
                <td>{{item.auditTime}}</td>
                <td><input type="text" v-model="item.auditAdvise"/></td>
            </tr>
        </table>
        <!--抄送人 和  付款人-->
        <table class="table-detail" style="border-top-width:0px;margin-bottom:20px;">
            <tr class="printDiv">
                <td class="td-title " style="width:16%;">审核人</td>
                <td class="" colspan="5">
                    <div v-for="(item,i) in repo.auditors" class="user">{{item.auditorName}};
                    </div>
                </td>
            </tr>
            <tr>
                <td class="td-title" style="width:20%;">抄送人</td>
                <td colspan="5">
                    <div id="user" style="padding-left:6px;"
                         v-on:click.stop="inputFocus('txtCopier')">
                        <div v-for="(user,i) in repo.copiers" class="user"
                             v-bind:class="{ select: copierSelectedIdx == i }"
                             v-on:click="selectUser(i,'copierSelectedIdx')">{{user.copierName}};
                        </div>
                        <input v-if="pageType=='edit'" class="pull-left copier" id="txtCopier"
                               style="width:100px"
                               type="text" @keyup.delete="deleteUser"/>
                    </div>
                </td>
            </tr>
            <tr v-if="repo.main.copierReturnReason">
                <td class="td-title" style="width:16%;">抄送人驳回原因</td>
                <td colspan="5" style="text-align:left;">
                    <span class="sp-value">{{repo.main.copierReturnReason}}</span>
                </td>
            </tr>
        </table>
        <!--出库记录-->
        <template v-if="repo.repoHistory && repo.repoHistory.length > 0">
            <table class="table-detail no-print" style="border-top-width:0px;">
                <tr>
                    <td class=" td-module" colspan="5" style="background: yellow;">出库记录</td>
                </tr>
                <tr>
                    <td class="td-title" style="width:16%;">出库日期</td>
                    <td class="td-title" style="width:17%;">出库人</td>
                    <td class="td-title" style="width:16%;">出库数量</td>
                    <!--<td class="td-title" style="width:17%;">领用人</td>-->
                    <td class="td-title" style="width:17%;">出库用途描述</td>
                    <td class="td-title">领用凭证</td>
                </tr>
                <tr v-for="(item,i) in repo.repoHistory">
                    <td>{{item.date}}</td>
                    <td>{{item.outUserName}}</td>
                    <td>{{item.count}}</td>
                    <!--<td>{{item.receiveUserName}}</td>-->
                    <td>{{item.remark}}</td>
                    <td >
                        <div id="">
                            <div v-for="(attach,i) in repo.attaches" class="fj-tanzhongStyle ">
                                <b :class="fjStyle(attach.name)"></b>
                                <div class="name" v-if="attach.name" :title="attach.name"
                                     v-on:click="download(attach.url,attach.name)">
                                    {{attach.name}}
                                </div>
                                <div class="down">
                                    <a href="javascript:void(0)" class="nui-txt-link"
                                       v-on:click="download(attach.url,attach.name)">
                                        下载
                                    </a>
                                </div>
                                <div class="del" v-if="pageType=='edit'">
                                    <a href="javascript:void(0)" class="nui-txt-link" v-on:click="deleteFile(i)">
                                        删除
                                    </a>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </template>
        <template v-else>

        </template>

        <div class="south no-print" style="height:50px;line-height:50px;text-align:center;">
            <template v-if="pageType == 'edit'">
                <input type="button" style="margin-left:20px;" value="草稿"
                       class="btn oaBtn btn-sm"
                       @click="save('-1')">
                <input type="button" style="margin-left:20px;" value="提交"
                       class="btn btn-primary btn-sm"
                       @click="save('0')">
            </template>
            <template v-if="currentUser.id==repo.main.currentAuditorId && pageType == 'audit'">
                <input type="button" style="margin-left:20px;" value="通过"
                       class="btn oaBtn btn-sm"
                       @click="applyAudit('1')">
                <input type="button" style="margin-left:20px;" value="驳回"
                       class="btn oaBtn btn-sm"
                       @click="copierReturn">
            </template>
        </div>
    </div>
</div>
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=8e743a31"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=54c6b89c"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/js/pages/common/commonService.js"></script>
<script type="text/javascript" src="/dist/js/pages/psi/repo/class.js"></script>
<script src="/dist/plugins/webuploader-0.1.5/webuploader.min.js"></script>
<!--ztree组件所需js-->
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.exhide-3.5.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne,.lineTwo,.lineF", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
    $(function () {
        $("body").on("click", ".selectModel", function (e) {
            if ($(".model-picker-dropdown").is(":hidden")) {
                $(".model-picker-dropdown").css({
                    "width": $(this).outerWidth() + "px",
                    "left": $(this).offset().left,
                    "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                }).show();
                e.stopPropagation();
            } else {
                $(".model-picker-dropdown").hide();
            }
        });
        $("body").on("click", ".model-select-tab a", function (e) {
            $(this).parent().find("a").removeClass("active");
            $(this).addClass("active");
            var boxName = $(this).attr("data-count");
            $(".model-select").hide();
            $(".model-select-content" + " ." + boxName).show();
        });
        $("body").on("click", ".model-select  a", function (e) {
            if ($(this).hasClass("active")) {
                return false;
            }
            $(this).parent().find("a").removeClass("active");
            var id = $(this).attr("attr-id");
            $(this).addClass("active");
            var val = $(this).text();
            if ($(this).parents(".model-select").hasClass("type")) {
                $(".model-select-tab a").removeClass("active");
                $(".model-select-tab a[data-count=brand]").addClass("active");
                $(".model-select").hide();
                app.track.main.provinceName = val;
                app.track.main.cityName = '';
                app.track.main.countyName = '';
                app.getCity(id);
                $(".model-select-content .brand").show();

            } else if ($(this).parents(".model-select").hasClass("brand")) {
                $(".model-select-tab a").removeClass("active");
                var id = $(this).attr("attr-id");
                $(".model-select-tab a[data-count=model]").addClass("active");
                $(".model-select").hide();
                app.track.main.cityName = val;
                app.track.main.countyName = '';
                app.getCounty(id);
                $(".model-select-content .model").show();

            } else {
                app.track.main.countyName = val;
                $(".model-picker-dropdown").hide();
                app.track.main.customerAddress = app.track.main.provinceName + app.track.main.cityName + app.track.main.countyName
                app.checkProp('customerAddress')
            }
        })
        $("body").on("click", ".model-picker-dropdown", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".model-picker-dropdown").hide();
        });
    });
    $(function () {
        $("body").on("click", ".moreList", function (e) {
            var tableName = $(this).attr("data-table");
            var column = $(this).attr("data-column");
            var columnName = $(this).attr("data-columnName");
            var mainKey = $(this).attr("data-column");
            var mid = $(this).attr("data-mid");
            var type = $(this).attr("data-type");
            if ($(this).hasClass("jiaobiao3")) {
                $.dialog({
                    content: 'url:/page/logs/logs.html?tableName=' + tableName + '&column=' + column + '&columnName=' + columnName + "&mainKey=" + mainKey + "&mid=" + mid + '&type=' + type + '&id=' + app.track.main.id,
                    title: '修改日志',
                    width: 600,
                    height: 500,
                    max: false,
                    min: false,
                    lock: true
                });
            }
        });
        $("body").on("click", ".moreListData", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".moreListData").hide();
        });
    });
</script>
<script type="text/javascript">
    var api = frameElement.api;
    function refresh() {

    }
    var app = new Vue({
        el: '#app',
        data: {
            id: $.wyui.page.urlParams.id ? $.wyui.page.urlParams.id : '',
            inventoryId: $.wyui.page.urlParams.inventoryId ? $.wyui.page.urlParams.inventoryId : '',
            pageType: $.wyui.page.urlParams.pageType,
            isAdd: $.wyui.page.urlParams.isAdd,
            currentUser: getCurrentUser(),
            companyList:[],
            myGoodsList: [],
            inventoryGoods:{
                main:{
                    id:'',
                    applyDate:new Date().Format('yyyy-MM-dd'),
                    companyName: getCurrentUser().companyName,
                    companyId: getCurrentUser().companyId,
                    departId: getCurrentUser().departId,
                    departName: getCurrentUser().departName,
                    method:'',
                    requirements:'',
                    goodsId:'',
                    goodsName:'',
                    purpose:'',
                    state:'0',
                    count:'',
                    createUserId:getCurrentUser().id,
                    createUserName:getCurrentUser().name
                },
                attaches: []//图片
            },
            copierSelectedIdx: -1,
            repo:{
                main:{
                    id:'',
                    date:new Date().Format("yyyy-MM-dd"),
                    companyName: getCurrentUser().companyName,
                    companyId: getCurrentUser().companyId,
                    departId: getCurrentUser().departId,
                    departName: getCurrentUser().departName,
                    goodsId:'',
                    outUserId:getCurrentUser().id,
                    outUserName:getCurrentUser().name,
                    keeperUserId:'',
                    keeperUserName:''
                },
                auditors:[
                    new Repo.Audit(),
                    new Repo.Audit()
                ],
                copiers: [],
                auditHistorys:[],
                repoHistory:[],
                attaches: []//图片
            }
        },
        methods: {
            hiddenDivModel: function () {
                $("#countyIdel").hide();
            },
            goBack: function () {
                api.close();
            },
            copierReturn: function () {
                var that = this;
                top.$.dialog({
                    content: 'url:/page/psi/inventoryCopierReturnReason.html?id='
                    + that.id + "&pageType=1" + "&t=" + new Date(),
                    title: '填写驳回原因',
                    width: 300,
                    height: 200,
                    max: false,
                    min: false,
                    lock: true
                });
            },
            showCopierReturn: function () {
                if (this.repo.main.auditFlag == '0') {
                    var copierIds = new Array();
                    for (var i = 0; i < this.repo.copiers.length; i++) {
                        copierIds.push(this.repo.copiers[i].copyPersonId);
                    }
                    return $.inArray(currentUser.id, copierIds) > -1;
                }
                return false;
            },
            deleteFile: function (i) {
                if (window.confirm("确定要删除该附件吗?")) {
                    this.repo.attaches.splice(i, 1);
                }
            },
            download: function (attachId, fileName) {
                downloadFile(attachId,fileName)
                return false;
            },
            goodsList: function () {
                var that = this;
                $.wyui.postMethod('/goods/getGoodsList.json',{companyId:that.companyId}, function (data) {
                    that.myGoodsList = data.records;
                    console.log(that.myGoodsList)
                })
            },
            save: function (auditFlag) {
                var that = this;
                delete that.repo.main.createTime;
                that.repo.main.inOutFlag = '0';
                that.repo.main.auditFlag = auditFlag;
                for (var i = 0; i < that.myGoodsList.length; i++) {
                    if (that.myGoodsList[i].goodsName == that.inventoryGoods.main.goodsName) {
                        that.repo.main.goodsId = that.myGoodsList[i].id;
                    }
                }
                $.wyui.postMethod(urlConfig.psi.repo.save, trimRN(that.repo), function (data) {
                    alert('提交成功');
                    var $iframe = top.findIframeByName("库存管理");
                    $iframe[0].contentWindow.refresh();
                    that.inventoryId = '';
                    /*api.close();*/
                    setTimeout(function () {
                        //某种bug，需要延迟执行
                        top.addTabs({
                            id: 'outRepoList',
                            title: '出库管理',
                            close: true,
                            url: 'psi/outRepoList.html'
                        });
                        api.close();
                    }, 100);
                })
            },
            convertAuditFlagToName: function (auditFlag) {
                //auditFlag:-1,0,1,2,3,4,5,6
                switch (auditFlag) {
                    case "-1":
                        return "未提交";
                        break;
                    case "0":
                        return "审核中";
                        break;
                    case "1":
                        return "通过";
                        break;
                    case "2":
                        return "驳回";
                        break;
                    default :
                        break;
                }
            },
            /* getrepoById:function () {
             var that = this;
             $.wyui.postMethod(urlConfig.psi.repo.getrepoById, {
             id: that.id
             }, function (data) {
             var params = {moduleId: data.main.id};
             commonService.getAttachesByModuleId(params, function (attaches) {
             if (attaches) {
             data.attaches = attaches;
             }
             that.repo = data;
             });
             })
             },*/
            //添加一行
            addItem: function (prop, className) {
                this.repo[prop].push(new Repo[className]());
                setTimeout(function () {
                    initAutoComplete();
                }, 300);

            },
            //删除一行
            delItem: function (prop, i, desc) {
                if (i == 0) {
                    alert("第一" + desc + "不能删除！")
                    return
                }
                this.repo[prop].splice(i, 1);
            },
            showDatePicker: function (e) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        that.repo.main.receiveDate = dp.cal.getNewDateStr();
                        return true;
                    },
                });
                $(e.target).blur();
            },
            applyAudit: function (auditFlag) {
                if (auditFlag == "2") {

                } else {
                    if (!confirm("确定要通过吗？")) {
                        return;
                    }
                }
                var that = this;
                var advise = '';
                for (var i = 0; i < this.repo.auditors.length; i++) {
                    if (this.repo.auditors[i].auditorId == this.currentUser.id) {
                        advise = this.repo.auditors[i].auditAdvise;
                        break;
                    }
                }
                if (auditFlag == '2' && advise == '') {
                    alert('请填写审核意见');
                    return;
                }
                if (advise == "") {
                    advise = "同意！";
                }
                $.wyui.postMethod(urlConfig.psi.repo.applyAudit, {
                    id: that.repo.main.id,
                    userId: getCurrentUser().id,
                    userName:getCurrentUser().name,
                    roleName:getCurrentUser().roleName,
                    auditFlag: auditFlag,
                    advise: advise
                }, function () {
                    alert("审核成功");
                    if (top.findTabPanelByName("出库管理")) {
                        var $iframe = top.findIframeByName("出库管理");
                        $iframe[0].contentWindow.refresh();
                    }
                    api.close();
                });
            },
            inputFocus: function (id) {
                $("#" + id).focus();
            },
            selectUser: function (i, prop) {
                this.copierSelectedIdx = -1;
                this[prop] = i;
            },
            unselectUser: function () {
                this.copierSelectedIdx = -1;
            },
            deleteUser: function (event) {
                if (event.keyCode == 46 || event.keyCode == 8 && event.target.value == "") {
                    if (this.copierSelectedIdx > -1) {
                        this.repo.copiers.splice(this.copierSelectedIdx, 1);
                        this.copierSelectedIdx = -1;
                    } else {
                        this.copierSelectedIdx = this.repo.copiers.length - 1;
                    }
                }
            },
            fjStyle: function (fjName) {
                if (fjName) {
                    var type = fjName.substring(fjName.lastIndexOf('.') + 1);
                    return 'img fj-' + type
                }
                return 'img'
            },
            getCompanyList:function () {
                var that = this;
                $.wyui.postMethod(urlConfig.system.company.getCompanyList,{},function (data) {
                    that.companyList = data;
                    console.log(data)
                });
            },
            init:function () {
                var that = this;
                this.uploader = WebUploader.create({
                    // 选完文件后，是否自动上传。
                    auto: true,
                    // swf文件路径
                    swf: "/statics/plugin/webuploader-0.1.5/Uploader.swf",
                    // 文件接收服务端。
                    server: server.fjIp + "/attach/uploadFile.json",
                    // 选择文件的按钮。可选。
                    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                    pick: '#divUpload',
                    duplicate: true
                });
                this.uploader.on("uploadStart", function () {
                    $("#progress").show();
                });
                this.uploader.on("uploadComplete", function () {
                    $("#progress").hide();
                });
                // 文件上传成功，给item添加成功class, 用样式标记上传成功。
                this.uploader.on('uploadSuccess', function (file, response) {
                    if (response._raw == "文件上传出错！") {
                        alert("文件上传出错！");
                    } else {
                        that.repo.attaches.push({
                            id: response.id,
                            name: response.name,
                            url: response.url
                        });
                    }
                });
                // 文件上传失败，显示上传出错。
                this.uploader.on('uploadError', function (file) {
                    alert("上传失败！");
                });
            }
        },
        mounted: function () {
            var that = this;
            if (that.inventoryId) {
                $.wyui.postMethod(urlConfig.psi.inventory.getInventoryGoodsInfoById, {id: that.inventoryId}, function (data) {
                    that.inventoryGoods = data;
                    console.log(that.inventoryGoods)
                });
            }
            //编辑
            if (parseInt($.wyui.page.urlParams.id) > 0) {
                $.wyui.postMethod(urlConfig.psi.repo.getRepoById, {id: $.wyui.page.urlParams.id}, function (data) {
                    var params = {moduleId: data.main.id};
                    commonService.getAttachesByModuleId(params, function (attaches) {
                        if (attaches) {
                            data.attaches = attaches;
                        }
                        that.repo = data;});
                    console.log(that.repo.auditors)
                });
            } else {
                $.wyui.postMethod(urlConfig.system.user.getFirstParent, {userId: getCurrentUser().id}, function (data) {
                    app.repo.auditors[0].auditorId = data.id;
                    app.repo.auditors[0].auditorName = data.roleName + "-" + data.name;
                });
            }
            that.getCompanyList();
            that.goodsList();
            that.init();
        }
    });
</script>
<script>
    $('[contenteditable]').each(function () {
        // 干掉IE http之类地址自动加链接
        try {
            document.execCommand("AutoUrlDetect", false, false);
        } catch (e) {
        }

        $(this).on('paste', function (e) {
            e.preventDefault();
            var text = null;

            if (window.clipboardData && clipboardData.setData) {
                // IE
                text = window.clipboardData.getData('text');
            } else {
                text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('在这里输入文本');
            }
            if (document.body.createTextRange) {
                if (document.selection) {
                    textRange = document.selection.createRange();
                } else if (window.getSelection) {
                    sel = window.getSelection();
                    var range = sel.getRangeAt(0);

                    // 创建临时元素，使得TextRange可以移动到正确的位置
                    var tempEl = document.createElement("span");
                    tempEl.innerHTML = "&#FEFF;";
                    range.deleteContents();
                    range.insertNode(tempEl);
                    textRange = document.body.createTextRange();
                    textRange.moveToElementText(tempEl);
                    tempEl.parentNode.removeChild(tempEl);
                }
                textRange.text = text;
                textRange.collapse(false);
                textRange.select();
            } else {
                // Chrome之类浏览器
                document.execCommand("insertText", false, text);
            }
        });
        // 去除Crtl+b/Ctrl+i/Ctrl+u等快捷键
        $(this).on('keydown', function (e) {
            // e.metaKey for mac
            if (e.ctrlKey || e.metaKey) {
                switch (e.keyCode) {
                    case 66: //ctrl+B or ctrl+b
                    case 98:
                    case 73: //ctrl+I or ctrl+i
                    case 105:
                    case 85: //ctrl+U or ctrl+u
                    case 117: {
                        e.preventDefault();
                        break;
                    }
                }
            }
        });
    });
</script>
<script>
    $(function () {
        initAutoComplete();
    });

    function initAutoComplete() {
        $(".auditorName,.copier").autoComplete({
            url: server.ip + urlConfig.system.user.getTop10ByNameUser,
            render: function (users, panel) {
                for (var i = 0; i < users.length; i++) {
                    $("<li></li>").data("autoComplete",
                        users[i]).html("<a>" + users[i].name + "&nbsp;&nbsp;&nbsp;" +
                        "(" + "&nbsp;" + users[i].companyName + "-" + users[i].departName + "-" + users[i].roleName + "&nbsp;" + ") " + "</a>")
                        .appendTo(panel);
                }
            },
            selected: function (user) {
                if ($(this).hasClass("auditorName")) {
                    var idx = $(this).attr("idx");
                    app.repo.auditors[idx].auditorId = user.id;
                    app.repo.auditors[idx].auditorName = user.roleName + "-" + user.name;
                } else if ($(this).hasClass("copier")) {
                    var userIds = new Array();
                    for (var i = 0; i < app.repo.auditors.length; i++) {
                        userIds.push(app.repo.auditors[i].auditorId);
                    }
                    for (var i = 0; i < app.repo.copiers.length; i++) {
                        userIds.push(app.repo.copiers[i].copierId);
                    }
                    if ($.inArray(user.id, userIds) == -1) {
                        app.repo.copiers.push({copierId: user.id, copierName: user.name});
                    } else {
                        alert("审核人、抄送人不能重复输入");
                    }
                    $(this).val("");
                }
                return false;
            },
            height: 210,
            width: 300
        });
    }
</script>
</body>
</html>